package com.woniuxy.commons.service;

import com.woniuxy.commons.entity.Goods;
import com.woniuxy.commons.service.factory.ProviderServiceFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author zhangyong
 * @Date 2021/8/3 0003
 */
// fallbackFactory指定fallback工厂类
@FeignClient(name = "PROVIDER", fallbackFactory = ProviderServiceFactory.class) //name指定调用的微服务名字
public interface ProviderService {
    //获取商品信息
    @GetMapping("/goods/all")
    public List<Goods> all();

    //以id查询商品信息 遵循restful风格
    @GetMapping("/goods/find/{id}")
    public Goods findById(@PathVariable("id") int id);

    //POST请求接收数据
    @PostMapping("/goods/add")
    public Boolean add(@RequestBody Goods goods);

    //put请求
    @PutMapping("/goods/update")
    public Boolean update(@RequestBody Goods goods);

    //delete请求
    @DeleteMapping("/goods/del/{id}")
    public void del(@PathVariable("id") int id);
}
